package com.goatrock.media.thisway.common.model;
/**
 * Designed for use by MyMoviesManager
 * @author COLER12
 */
public abstract class BaseDTO {

    public String[] addElementToStringArray(String newElement, String[] oldInputElement){
        String[] oldElement;
        if (oldInputElement == null) {
            oldElement = new String[0];
        }else{
            oldElement = oldInputElement.clone();
        }
        String[] newStringArr = new String[oldElement.length+1];
        for (int i=0; i < oldElement.length;i++){
            newStringArr[i] = oldElement[i];
        }
        newStringArr[oldElement.length] = newElement;
        return newStringArr;
    }

    public String[] removeElementFromStringArray(int index, String[] oldInputElement){
        String[] oldElement;
        if (oldInputElement == null) {
            oldElement = new String[0];
        }else{
            oldElement = oldInputElement.clone();
        }
        String[] newStringArr = new String[oldElement.length-1];
        int count = 0;
        for (int i=0; i < oldElement.length;i++){
            if (i != index){
                newStringArr[count] = oldElement[i];
                count++;
            }
        }
        return newStringArr;
    }

    public long[] addElementToLongArray(long newElement, long[] oldInputElement){
        long[] oldElement;
        if (oldInputElement == null) {
            oldElement = new long[0];
        }else{
            oldElement = oldInputElement.clone();
        }
        long[] newIntArr = new long[oldElement.length+1];
        for (int i=0; i < oldElement.length;i++){
            newIntArr[i] = oldElement[i];
        }
        newIntArr[oldElement.length] = newElement;
        return newIntArr;
    }
}
